<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.view');
class ReviewsViewReview extends JView
{
//I don't understand why this view have to use this contructor ,otherwise 
	//name=sviewall ==>default.php will not found==>Throw exception code:500-Default not found
	function __construct( $config = array() ) {
	//setting properly name for this view
      $config['name'] = 'review';
      parent::__construct( $config );

   }
  function display($tpl = null)
  {
    global $option, $mainframe;
    //Ger reviewModel
    $model = &$this->getModel();
    //Get user
    $user =& JFactory::getUser();
    $review = $model->getReview();
    //Get comment from Model
    $comments = $model->getComments();
    ///Create breadcrumbs pathway
    $pathway =& $mainframe->getPathWay();
    //Create back link
    $backlink = JRoute::_('index.php?option='.$option . '&view=all' );
    
    $review->review_date =JHTML::Date($review->review_date);
                 if($review->smoking == 1)
    {
      $review->smoking = "Yes";
    }
    else
    {
      $review->smoking = "No";
    }
    for($i = 0; $i < count($comments); $i++)
    {
      $row =& $comments[$i];
      $row->comment_date =JHTML::Date($row->comment_date);
    }
    /*The member function addItem() allows you to add a breadcrumb with the 
	title of your choice. The first parameter is the title for the breadcrumb, 
	while the second parameter is the URL*/
    $pathway->addItem($review->name, '');
    $this->assignRef('review', $review);
    $this->assignRef('comments', $comments);    
    $this->assignRef('backlink', $backlink);    
    $this->assignRef('option', $option);    
    $this->assignRef('name', $user->name);    
    parent::display($tpl);
  }
}
?>